home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / WindowPicker.cpp < prev    next >
Text File  |  1997-08-26  |  3KB  |  100 lines

  1. /*
  2.  *    File:        WindowPicker.cpp
  3.  *    Function:    A dialog that lets the user pick which window type he wants to create.
  4.  *    Written by:    Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *    Change History (most recent first):
  10.  *
  11.  *         <->    12/24/96    JDJ        Created
  12.  */
  13.  
  14. #include "WindowPicker.h"
  15.  
  16. #include <ZApplication.h>
  17. #include <ZDialogHandler.h>
  18.  
  19. #include "DialogBoxProxy.h"
  20. #include "DocWindowProxy.h"
  21. #include "ToolWindowProxy.h"
  22. #include "WindowProxy.h"
  23.  
  24.  
  25. // ===================================================================================
  26. //    Global Functions
  27. // ===================================================================================
  28.  
  29. //---------------------------------------------------------------
  30. //
  31. // PickWindow
  32. //
  33. //---------------------------------------------------------------
  34. TWindow* PickWindow(MCommander* superCommander)
  35. {
  36.     TWindow* window = nil;
  37.     
  38.     TDialogBox* dialog = dynamic_cast<TDialogBox*>(TDialogBox::Create(200, TApplication::Instance()));
  39.  
  40.     static short value = 1;
  41.     TControl* popup = dynamic_cast<TControl*>(dialog->FindSubPane("Picker"));
  42.     popup->SetValue(value);
  43.  
  44.     string message = kNothingMessage;
  45.  
  46.     {
  47.     TDialogHandler handler(dialog);
  48.     dialog->Show();
  49.  
  50.         while (message != kCancelMessage && message != kOKMessage) {
  51.             message = handler.ProcessNextEvent();
  52.  
  53.             if (message == kOKMessage)
  54.                 value = popup->GetValue();
  55.         }
  56.     }
  57.  
  58.     if (message == kOKMessage) {                
  59.         switch (value) {
  60.             case 1:                                // TWindow
  61.                 {
  62.                 SWindowAttr attr(kRegularLayer);
  63.                 SPaneInfo paneInfo("", TRect(32, 32, 256+32, 256+32));
  64.                 SWindowInfo windInfo(paneInfo, attr);
  65.                 window = new CWindowProxy(windInfo, superCommander);
  66.                 }
  67.                 break;
  68.                 
  69.             case 2:                                // TDocWindow
  70.                 {
  71.                 SWindowAttr attr(kRegularLayer);
  72.                 SPaneInfo paneInfo("", TRect(32, 32, 256+32, 256+32));
  73.                 SWindowInfo windInfo(paneInfo, attr);
  74.                 window = new CDocWindowProxy(windInfo, superCommander);
  75.                 }
  76.                 break;
  77.                 
  78.             case 3:                                // TToolWindow
  79.                 {
  80.                 SWindowAttr attr(kFloatingLayer);
  81.                 SPaneInfo paneInfo("", TRect(32, 32, 256+32, 256+32));
  82.                 SWindowInfo windInfo(paneInfo, attr);
  83.                 window = new CToolWindowProxy(windInfo, superCommander);
  84.                 }
  85.                 break;
  86.                 
  87.             case 4:                                // TDialogBox
  88.                 {
  89.                 SWindowAttr attr(kModalLayer);
  90.                 SPaneInfo paneInfo("", TRect(32, 32, 256+32, 256+32));
  91.                 SWindowInfo windInfo(paneInfo, attr);
  92.                 window = new CDialogBoxProxy(windInfo, superCommander);
  93.                 }
  94.                 break;                
  95.         }
  96.     }
  97.     
  98.     return window;
  99. }
  100.